// 主界面
;define(function(require, exports, module) {
    'use strict';
    var util = require("util");
    var base = require(CONFIG.BasePath + "js/enterprise/base");
    var router = require("../hash/pageRouter");
    var constant = require("constant");
    var css_detail = require("./myFinanceBill.css");
    var databind = require("databind");
    var pageIndex = 1,
		pageSize = 10,
		totalPageCount = 1,
		totalRecordCount = 0; //分页初始化
    
    var init = function(){
    	router.init();
    	inquireFinanceCommissionInfoPageList();
		initEvent();
    };
    
	var initEvent = function(){
		if(base.getData("sid")==null){
			location.href="../login/login.html";
		}
		
    };
    
	//企业查询融资信息列表
    var inquireFinanceCommissionInfoPageList = function(){
		base.fnAjax({
			action: "inquireFinanceCommissionInfoPageList.json",
			async: false,
			oData: {
                pageSize: pageSize,
           		pageIndex: pageIndex,
           		type: 0
            }, //传递参数
            fnSuccess: function(data) {
                if (data.status == 200) {
                	juicer.register("getValueByKey", constant.getValueByKey);
                	var tpl = $("#myFinanceBill script").html();
                	var html = juicer(tpl, data);
                	$("#myFinanceBill table").html(html);
                	$(".cancelApplication").unbind("click").click(function(){
                	});
                	
                	$("#myFinanceBill .accountRecordDetail").unbind("click").click(function(){
                		router.route("account/commissionDetail.html?financeId="+$(this).parents("tr").attr("financeId") + "&expenseItem=罚款");
                	});
                	totalPageCount = data.totalPageCount;
					totalRecordCount = data.totalRecordCount;
                	base.pageControl($("#myFinanceBill .pagerCon"),
						totalRecordCount,
						data.pageIndex,
						data.pageSize,
						function(p) {
							pageIndex = p;
							inquireFinanceCommissionInfoPageList();
						});
                } else {
//                  base.alert(2,"信息获取失败");
                }
            }
		});
	};
	
    return {
        init:init
    };
});